/*--------------------------------------------------------------
 * File: ledRGB.c 编码类型：C语言  UTF-8
 * Author WRS (1352509846@qq.com)
 * 功能: LED灯驱动程序
 * Version 0.1
 * Date 2024-11-25 
 * 
 * @copyright Copyright (c) 2024
 * 
----------------------------------------------------------------*/

#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_timer.h"
#include "esp_err.h"
#include "esp_log.h"
#include "driver/gpio.h"
#include "ledRGB.h"

#define R_LED_GPIO 2
#define G_LED_GPIO 5
// #define B_LED_GPIO 25 // 管脚25是接扬声器的，最后不要使用

void LED_init(void)
{
    // ESP_LOGI(TAG, "Example configured to blink GPIO LED!");
    gpio_reset_pin(R_LED_GPIO);
    gpio_reset_pin(G_LED_GPIO);
    // gpio_reset_pin(B_LED_GPIO);

    /* Set the GPIO as a push/pull output */
    gpio_set_direction(R_LED_GPIO, GPIO_MODE_OUTPUT);
    gpio_set_direction(G_LED_GPIO, GPIO_MODE_OUTPUT);
    // gpio_set_direction(B_LED_GPIO, GPIO_MODE_OUTPUT);

    gpio_set_level(R_LED_GPIO, LED_OFF);
    gpio_set_level(G_LED_GPIO, LED_OFF);
    // gpio_set_level(B_LED_GPIO, LED_OFF);
}

void R_LED_SET(LED_State_e s_led_state) 
{
    gpio_set_level(R_LED_GPIO, s_led_state);
}

void G_LED_SET(LED_State_e s_led_state) 
{
    gpio_set_level(G_LED_GPIO, s_led_state);
}

void B_LED_SET(LED_State_e s_led_state) 
{
    // gpio_set_level(B_LED_GPIO, s_led_state);
}